home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18282 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  41 lines

  1. Path: news.th-darmstadt.de!news
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Default values
  5. Date: 19 Apr 1996 20:15:46 +0200
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Sender: enno@kitz.inferenzsysteme.informatik.th-darmstadt.de
  8. Message-ID: <ltbukoqdv1.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <26418@829921816>
  10. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  11. In-reply-to: "dan j"'s message of Fri, 19 Apr 1996 08:50:13 -0500 (EST)
  12. X-Newsreader: Gnus v5.1
  13.  
  14. In article <26418@829921816> "dan j" <djacobso@cs.indiana.edu> writes:
  15.  
  16.    Is it somehow possible to use a class member variable as a default
  17.    value to a member function?  When, if ever, can variables serve as
  18.    default values?  For instance,
  19.  
  20.    class tree {
  21.      tree_node * root;
  22.  
  23.    public:
  24.      ...
  25.      foo(tree_node * ptr = root) { (recursive); }
  26.      ...
  27.    };    
  28.  
  29.    g++ (SunOS) says 'root' is not defined in this scope. 
  30.  
  31.    A special function foo2() called with 'root' serves the purpose:
  32.  
  33.      foo(tree_node * ptr) { (recursive); }
  34.      foo2(void) { foo(root); }
  35.  
  36.    But what is a better way to handle this?
  37.  
  38. For a nonstatic-member it's not possible (check out DWP 8.3.6.9)
  39.  
  40.         Enno
  41.